<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>我的</title>
		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<script src="../js/mui.min.js"></script>
		<script src='../js/jquery.min.js'></script>
		<style>
			.mui-content{
				margin: 10px;
				padding: 10px;
			}
			.mui-btn{
				width: 100%
			}
		</style>

	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">编辑资料</h1>
		</header>

		<div class="mui-content">
			<div class="mui-input-row mui-password">
				<input type="password" class="mui-input-password" placeholder="请输入原始密码" id="pwd1">
			</div>

			<div class="mui-input-row mui-password">
				<input type="password" class="mui-input-password" placeholder="请输入新密码" id="pwd2">
			</div>

			<div class="mui-input-row mui-password">
				<input type="password" class="mui-input-password" placeholder="请再次输入新密码" id="pwd3">
			</div>

			<button class="mui-btn mui-btn-primary" id="submit">提交</button>
		</div>


	</body>
	<script>
		var u;
		
		mui.plusReady(function() {
			u = plus.storage.getItem('user_id');
		});

		document.getElementById("submit").addEventListener('tap', function(e) {
			var pwd1 = jQuery("#pwd1").val();
			var pwd2 = jQuery("#pwd2").val();
			var pwd3 = jQuery("#pwd3").val();
			if (pwd2 !== pwd3) {
				mui.toast("两次输入的密码不一致");
				return;
			}
			var obj = {
				id: u,
				pwd1: pwd1,
				pwd2: pwd2
			};
			mui.ajax({
				url: '',
				type: "post",
				async: false,
				data: obj,
				dataType: "json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8",
				jsonp: "jsoncallback",
				success: function(data) {
					if (data.suc) {
						mui.toast("修改成功");
					} else {
						mui.toast("修改失败");
					}
				},
				error: function() {
					mui.toast("服务器异常，请稍后再试");
				}
			});
		});
	</script>

</html>
